package com.e3.basdoc.tax.client;

import java.util.List;

import com.e3.basdoc.tax.model.TaxModel;
import com.e3.basdoc.tax.model.TaxQC;
import com.e3.template.tgf.TGFQueryDialog;
import com.e3.web.core.client.GwtAsyncCallback;
import com.e3.web.core.model.SuperQC;
import com.e3.web.widget.client.MyField;
import com.extjs.gxt.ui.client.widget.form.Field;

public class TaxQueryDialog extends TGFQueryDialog<TaxModel> {
	
	private TaxRPCServiceAsync service = TaxRPCService.Util.getInstance();

	@Override
	protected List<Field<?>> getFormFields() {
		return TaxHelper.INSTANCE.getFormFields();
	}

	@Override
	protected SuperQC getQueryCondition() {
		MyField<?> field = getMyFormField(TaxModel.CODE);
		String code = (String)field.getFieldValue();
		field = getMyFormField(TaxModel.NAME);
		String name = (String)field.getFieldValue();
		
		final TaxQC qc = new TaxQC();
		qc.setCode(code);
		qc.setName(name);

		return qc;
	}

	@Override
	protected void executeQueryService(SuperQC qc,GwtAsyncCallback<List<TaxModel>> callback) {
		service.getTaxByCondition((TaxQC)qc, getQueryAsyncCallBack(qc));
	}
}
